
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package nac.firefight;

//~--- non-JDK imports --------------------------------------------------------

import net.phys2d.raw.shapes.DynamicShape;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

/**
 *
 * @author User
 */
public class AnimatedSprite extends Sprite {
    private Animation[] animations = new Animation[1];
    private int drawIndex = 0;

    public AnimatedSprite(Animation[] animations, String name, DynamicShape shape, float m) throws SlickException {
        super(new Image(0,0), name, shape, m);
       
        this.animations = animations;
    }

    public AnimatedSprite(Animation animation, String name, DynamicShape shape, float m) throws SlickException {
        super(new Image(0,0), name, shape, m);

        this.animations[0] = animation;
    }

    public Animation getAnimation(int i) {
        return animations[i];
    }

    public int getDrawIndex() {
        return drawIndex;
    }

    public void setDrawIndex(int drawIndex) {
        this.drawIndex = drawIndex;
    }

   
    @Override
    public void draw() {
        animations[drawIndex].draw(getPosition().getX() - (animations[0].getWidth() / 2),
                           getPosition().getY() - (animations[0].getHeight() / 2));
        animations[drawIndex].getCurrentFrame().setRotation((float) Math.toDegrees(getRotation()));
    }

    public void draw(int i) {
       
        animations[i].draw(getPosition().getX() - (animations[0].getWidth() / 2),
                           getPosition().getY() - (animations[0].getHeight() / 2));
        animations[i].getCurrentFrame().setRotation((float) Math.toDegrees(getRotation()));
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
